﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="demoCookies.aspx.cs" Inherits="demoCookies_demoCookies" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>未命名頁面</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.js"></script>
    <script src="jquery.cookie.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
      <asp:Button ID="Button1" runat="server" Text="Button" />
    </div>
    <script type="text/javascript">
      $(function(){
        
        var val = $.cookie('TextBox1');
        if(val)
        {
          $('#TextBox1').val(val);
        }
        
        $('#Button1').click(function(){
          // save to cookies
          var val = $('#TextBox1').val();
          $.cookie('TextBox1', val);
        });
      });
    </script>
    </form>
</body>
</html>
